package com.ruoyi.base.exception;

import com.ruoyi.base.enums.ExceptionEnum;
import lombok.Getter;

/**
 * 自定义异常
 *
 * @author ruoyi
 */
public class SysException extends RuntimeException {
    private static final long serialVersionUID = 1L;

    @Getter
    private Integer code;
    @Getter
    private String msg;

    @Override
    public String getMessage() {
        return this.msg;
    }

    public SysException(String msg) {
        this.code = ExceptionEnum.ERROR.getCode();
        this.msg = msg;
    }

    public SysException(Exception e) {
        this.code = ExceptionEnum.ERROR.getCode();
        this.msg = e.getMessage();
    }

    public SysException(ExceptionEnum e) {
        this.code = e.getCode();
        this.msg = e.getMsg();
    }

    public SysException() {
        this.code = ExceptionEnum.ERROR.getCode();
        this.msg = ExceptionEnum.ERROR.getMsg();
    }
}
